package com.swt.controller;

import com.swt.common.vo.ResponseVo;
import com.swt.domain.TbUserAddr;
import com.swt.service.TbUserAddrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 * @Author swt
 * @Date 2022/5/17
 */
@RestController
@RequestMapping("/TbUserAddr")
public class TbUserAddrController {
    @Autowired
    public TbUserAddrService tbUserAddrService;
    @PostMapping("/{count}/{size}")
    public ResponseVo pageTbUser(@PathVariable Integer count, @PathVariable Integer size){
        return ResponseVo.SUCCESS(tbUserAddrService.pageUserAddr(count,size));

    }
    @DeleteMapping("/{id}")
    public ResponseVo deleteTbUser(@PathVariable String id){
        return tbUserAddrService.delectUserAddr(id)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }

    /**
     * 根据用户ID查询地址
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public ResponseVo selectTbUserById(@PathVariable String id){
        return ResponseVo.SUCCESS(tbUserAddrService.selectbyUserAddrdid(id));
    }
    @PostMapping("/add/{userId}")
    public ResponseVo insertTbUser(@PathVariable String userId,@RequestBody TbUserAddr s){
        return tbUserAddrService.inserUserAddr(userId,s)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
    @PutMapping
    public ResponseVo updateTbUser(@RequestBody TbUserAddr s){
        return tbUserAddrService.updateUserAddr(s)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }

}

